<?php

class Upload extends Controller {

	function Upload()
	{
		parent::Controller();
		$this->load->helper(array('form', 'url'));
                $this->load->library('upload');
	}

	function index()
	{
             $data['main_content'] = 'upload_form';
		$this->load->view('includes/template', $data, array('error' => ' ' ));
	}

	function do_upload()
	{
		$config['upload_path'] = './uploads';
                $config['file_path'] = './uploads/';
		$config['allowed_types'] = 'gif|jpg|png';
		$config['max_size']	= '100';
		$config['max_width']  = '1024';
		$config['max_height']  = '768';

		$this->load->library('upload', $config);
                $this->upload->initialize($config);


		if ($this->upload->do_upload())
		{
			$data['upload_data'] = $this->upload->data();

                        $upload_data = $this->upload->data();
                        //$file_path = $upload_data->file_name;

                        //INSERT CODE HERE TO STORE IN THE DATABASE.

			$this->load->view('upload_success', $data);
		}
                else
                {
			$data['error'] = $this->upload->display_errors();

			$this->load->view('upload_form', $error);
		}
		
		
	}
}
?>